// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';

import 'package:flutter_rider/main/widgets/ext/u_layout.dart';
import 'package:flutter_rider/main/widgets/ext/u_text.dart';
import 'package:flutter_rider/main/widgets/ui_constant.dart';
import 'package:flutter_rider/routers/fluro_navigator.dart';
import 'package:flutter_rider/utils/screen_fit.dart';

class BottomSheetDialog extends StatelessWidget {
  final Function gdAction;
  final Function txAction;

  const BottomSheetDialog({
    Key? key,
    required this.gdAction,
    required this.txAction,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return IntrinsicHeight(
      child: Column(children: [
        Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(
                topLeft: Radius.circular(12.rpx),
                topRight: Radius.circular(12.rpx)),
          ),
          padding: EdgeInsets.only(top: 16.rpx, bottom: 16.rpx),
          alignment: Alignment.center,
          child: UText.get("高德地图", UIColor.color_black, 16.rpx),
        ).onTap(() {
          gdAction();
        }),
        0.5.hLine,
        Container(
          padding: EdgeInsets.only(top: 16.rpx, bottom: 16.rpx),
          alignment: Alignment.center,
          color: Colors.white,
          child: UText.get("腾讯地图", UIColor.color_black, 16.rpx),
        ).onTap(() {
          txAction();
        }),
        8.hLine,
        Container(
          padding: EdgeInsets.only(top: 16.rpx, bottom: 16.rpx),
          alignment: Alignment.center,
          color: Colors.white,
          child: UText.get("取消", UIColor.color_black, 16.rpx),
        ).onTap(() {
          NavigatorUtils.goBack(context);
        }),
        Container(
          height: ScreenUtil.getInstance().bottomBarHeight,
          color: Colors.white,
        ),
      ]),
    );

    // return _bottomSheet(context); //使用这个有很多问题，直接自定义
  }

  BottomSheet _bottomSheet(context) {
    return BottomSheet(
      onClosing: () {},
      builder: (context) {
        return IntrinsicHeight(
          child: Column(children: [
            Container(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(12.rpx),
                    topRight: Radius.circular(12.rpx)),
              ),
              padding: EdgeInsets.only(top: 16.rpx, bottom: 16.rpx),
              alignment: Alignment.center,
              child: UText.get("高德地图", UIColor.color_black, 16.rpx),
            ),
            0.5.hLine16,
            Container(
              padding: EdgeInsets.only(top: 16.rpx, bottom: 16.rpx),
              alignment: Alignment.center,
              color: Colors.white,
              child: UText.get("腾讯地图", UIColor.color_black, 16.rpx),
            ),
            8.hLine,
            Container(
              padding: EdgeInsets.only(top: 16.rpx, bottom: 16.rpx),
              alignment: Alignment.center,
              color: Colors.white,
              child: UText.get("取消", UIColor.color_black, 16.rpx),
            ),
            Container(
              height: ScreenUtil.getInstance().bottomBarHeight,
              color: Colors.white,
            ),
          ]),
        );
      },
    );
  }
}
